package com.evon.yardmanagement.transformer;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

import org.springframework.beans.BeanUtils;

import com.evon.yardmanagement.model.Car;
import com.evon.yardmanagement.model.Yard;
import com.evon.yardmanagement.model.Yard;
import com.evon.yardmanagement.ui.dto.YardDTO;
import com.evon.yardmanagement.ui.dto.transaction.CarDTO;

public class YardTransformer {
	
	public static YardDTO transform(Yard yard){
		return new BaseTransformer<Yard, YardDTO>(Yard.class, YardDTO.class).transformToDTO(yard);
	}
	public static Yard transformCreateYard(YardDTO yardDto){
		return new BaseTransformer<Yard, YardDTO>(Yard.class, YardDTO.class).transformToModel(yardDto);
//		Yard yard = new Yard();
//		//yard.setId(yardDto.getYardId());
//		yard.setName(yardDto.getYardName());
//		yard.setAddress(yardDto.getYardAddress());
//		yard.setCity(yardDto.getYardCity());
//		yard.setPhone(yardDto.getYardPhone());
//		return yard;
	}
	
	public static List<YardDTO> transform(List<Yard> yards) {
		if (yards == null || yards.isEmpty()) {
			return Collections.EMPTY_LIST;
		}
		List<YardDTO> listDTO = new ArrayList<YardDTO>(yards.size());
		for (Yard yard : yards) {
			YardDTO transientCar = new YardDTO();

			BeanUtils.copyProperties(yard, transientCar, new String[] {
					"HSC_ID", "HSC_TS", "HSU_ID", "HSU_TS" });
			listDTO.add(transientCar);
		}
		return listDTO;

	}

	
}
